home *** CD-ROM | disk | FTP | other *** search
- /* main.cpp
- *
- * This is the actual core which makes this thing fly.
- */
-
- #include <string.h>
- #include <XApplication.h>
- #include <XWindow.h>
- #include <XDialog.h>
- #include <XPrinter.h>
-
- /************************************************************************/
- /* */
- /* Printer Test */
- /* */
- /************************************************************************/
-
- /* DoPageSetup
- *
- * Page setup
- */
-
- static void DoPageSetup(void)
- {
- GPrinter.PageSetup();
- }
-
- /* PrintPage
- *
- * Print a test page
- */
-
- static void PrintPage(XGPrinter *p)
- {
- Rect r;
- XGDraw draw(p);
-
- r = p->PrintSize();
-
- #if OPT_MACOS == 1
- ::MoveTo(r.left+5,r.top+30);
- ::DrawString("\pThis is a simple page printout test");
- #endif
-
- #if OPT_WINOS == 1
- ::DrawText(draw.GetDC(),"This is a simple page printout test",
- -1,&r,DT_SINGLELINE | DT_TOP | DT_NOPREFIX);
- #endif
- }
-
- /* DoPrintTest
- *
- * Print test
- */
-
- static void DoPrintTest(void)
- {
- short s,e;
-
- if (GPrinter.PrintJob(&s,&e)) {
- /*
- * Print a test page
- */
-
- if (GPrinter.StartJob("NewGUI6 Print Test")) {
- if (GPrinter.StartPage()) {
- PrintPage(&GPrinter);
- GPrinter.EndPage();
- }
- GPrinter.EndJob();
- }
- }
- }
-
- /************************************************************************/
- /* */
- /* My app */
- /* */
- /************************************************************************/
-
- /* TMyApp
- *
- * My application
- */
-
- class TMyApp : public XGAppSingleWindow {
- public:
- long ReceiveDispatch(long msg, long arg, void *parg);
- };
-
- /* TMyApp::ReceiveDispatch
- *
- * Do my test
- */
-
- long TMyApp::ReceiveDispatch(long msg, long arg, void *parg)
- {
- if (!IsModalWindow()) {
- if (msg == KEventDoMenuCommand) {
- if (arg == 102) {
- DoPageSetup();
- return 1;
- }
- if (arg == 103) {
- DoPrintTest();
- return 1;
- }
- } else if (msg == KEventGetMenuStatus) {
- if ((arg >= 100) || (arg <= 103)) {
- ((XGSMenuStatusRecord *)parg)->enable = true;
- return 1;
- }
- }
- }
-
- return XGAppSingleWindow::ReceiveDispatch(msg,arg,parg);
- }
-
- /************************************************************************/
- /* */
- /* Main entry point */
- /* */
- /************************************************************************/
-
- /* StartApplication
- *
- * This starts up the application
- */
-
- XGAppCore *StartApplication(void)
- {
- XGAppSingleWindow *aw;
- XGWindow *w;
- XGSWindowInitRecord wi;
-
- /*
- * Start application engine
- */
-
- aw = new TMyApp;
-
- /*
- * Start window
- */
-
- wi.fViewType = 'wind';
- wi.windowType = KWinTypeDocument;
- wi.windowID = 0;
- wi.fVisible = true;
- wi.screenLeft = 0;
- wi.screenTop = 0;
- wi.screenRight = 205;
- wi.screenBottom = 331;
-
- wi.minx = -1;
- wi.miny = -1;
- wi.maxx = -1;
- wi.maxy = -1;
- wi.initx = -1;
- wi.inity = -1;
- wi.zoomx = -1;
- wi.zoomy = -1;
-
- strcpy(wi.windowName,"Test window");
- w = new XGWindow(wi);
-
- /*
- * Done. Return
- */
-
- return aw;
- }
-